Function Open MS Access File

Function OpenAccess. Put this function in the Modules of your access file

Public Sub OpenAccess(conPath As String)
   Dim objAccess As Access.Application
   'Create an instance of the Access application object.
   Set objAccess = CreateObject("Access.Application")
   'Access and display the application window.
   objAccess.OpenCurrentDatabase conPath
   objAccess.visible = True
   objAccess.DoCmd.RunCommand acCmdAppMaximize
   Application.DoCmd.RunCommand acCmdAppMinimize
End Sub

Call function on click command to open access file from filepath

Private Sub Command23_Click()
Dim FilePath As String
'Assign your own file path
FilePath = "C:\MyDatabase\MEMO.accdb"
Call OpenAccess(FilePath)
DoCmd.Quit
End Sub

Related posts